<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 组件</title>
    <style>
        #app {
        margin:  auto 40%;
    }
        .laoshu{
           margin-left: 20px;
        }
        .cat{
            /* background-color: red; */
            border: solid 1px red;
            width: 300px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div id="app">
        <blog :bloglist="bloglist">

        </blog>
    </div>

    <script src="../Day1/js/vue.js"></script>

    <script>
        //子组件
        Vue.component('blog',{
            props:['bloglist'],
            data:function(){
                return{

                }
            },
            template:`<div>
                <div class='cat' v-for='list in bloglist' :key='list.id'>

                    <h3>{{list.title}}</h3>

                    <p>{{list.date}}</p>
                    
                    <div class='laoshu'>
                        <img v-for='img in list.imgs' :src='img' width='80px' heigth='20px'/> 
                    </div>


                    </div>
                </div>`
        })
        //父
        var vm=new Vue({
            el:'#app',
            data:{
                bloglist: [
            { id: 1, title: 'AAA' ,date:'2022-3-1',imgs:['/image/wallhaven-1pwq23_2560x1600.png',
            '/image/wallhaven-85po71_2560x1600.png','/image/wallhaven-exrj5r_2560x1600.png'] },
            { id: 2, title: 'BBB' ,date:'2022-3-2',imgs:['/image/wallhaven-1pwq23_2560x1600.png','/image/wallhaven-exrj5r_2560x1600.png'] },
            { id: 3, title: 'CCC' ,date:'2022-3-3',imgs:['/image/wallhaven-85po71_2560x1600.png'] },
        ]
            },
            components:{
            }
        });
    </script>
</body>
</html>